#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<vector<int>> findMatrix(vector<int>& nums) {
        unordered_map<int, int> hash;
        vector<vector<int>> res;
        for (const auto& e : nums)
        {
            if (hash[e] >= res.size())
                res.push_back(vector<int>(1, e));
            else
                res[hash[e]].push_back(e);
            ++hash[e];
        }
        return res;
    }
};